package org.kzwl.book.controller.app;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.comment.AddCommentBO;
import org.kzwl.comm.pojo.bo.meeting.AddMeetingBO;
import org.kzwl.comm.pojo.bo.meeting.DelMeeting;
import org.kzwl.comm.pojo.bo.meeting.JoinMeetingBO;
import org.kzwl.comm.pojo.bo.meeting.QueryMeetingBasic;
import org.kzwl.comm.pojo.dto.meeting.JoinMeetingDTO;
import org.kzwl.comm.pojo.dto.meeting.MeetingBasicDTO;
import org.kzwl.comm.pojo.dto.meeting.MeetingDetailsDTO;
import org.kzwl.service.app.MeetingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/app-meeting")
@Api("会议")
public class CuMeetingController {

    @Autowired
    private MeetingService meetingService;

    @ApiOperation(value = "创建会议",notes = "cuUserId(用户编号)--必填 cuMeetingName(会议名称)--必填 cuMeetingEndDate(结束时间) cuMeetingStart(开始时间)--必填 cuMeetingPwd(会议密码)--必填")
    @PostMapping("/addMeeting")
    public ResponseData<Void> addMeeting(@RequestBody AddMeetingBO bo) {
        meetingService.addMeeting(bo);
        return new ResponseData<>();
    }

    @ApiOperation(value = "快速会议",notes = "cuMeetingPwd(会议密码)--必填")
    @PostMapping("/quickMeeting")
    public ResponseData<JoinMeetingDTO> quickMeeting(@RequestBody AddMeetingBO bo) {
        JoinMeetingDTO dto = meetingService.quickMeeting(bo);
        return new ResponseData<>(dto);
    }

    @ApiOperation(value = "查询会议",notes = "只需要填分页参数")
    @PostMapping("/queryBasic")
    public ResponseData<List<MeetingBasicDTO>> queryBasic(@RequestBody QueryMeetingBasic bo) {
        List<MeetingBasicDTO> list = meetingService.queryBasic(bo);
        return new ResponseData<>(list);
    }

    @ApiOperation(value = "查询会议详细",notes = "cuMeetingId(id)--必填")
    @PostMapping("/queryDetails")
    public ResponseData<MeetingDetailsDTO> queryDetails(@RequestBody QueryMeetingBasic bo) {
        MeetingDetailsDTO dto = meetingService.queryDetails(bo);
        return new ResponseData<>(dto);
    }

    @ApiOperation(value = "加入会议",notes = "cuMeetingCode(回忆口令)--必填 cuUserId(用户id)--必填 cuMeetingPwd(会议密码) cuMeetingName(当前用户名)--必填")
    @PostMapping("/joinMeeting")
    public ResponseData<JoinMeetingDTO> joinMeeting(@RequestBody JoinMeetingBO bo) {
        JoinMeetingDTO dto = meetingService.joinMeeting(bo);
        return new ResponseData<>(dto);
    }

    @ApiOperation(value = "删除会议",notes = "cuUserId(用户编号)--必填 cuMeetingId(会议id)--必填")
    @PostMapping("/delMeeting")
    public ResponseData<Void> delMeeting(@RequestBody DelMeeting bo) {
        meetingService.delMeeting(bo);
        return new ResponseData<>();
    }
}
